package com.project.handlChain;

import com.project.handle.RiskHandle;
import com.project.pojo.RiskController;
import com.project.utils.ErrorMessage;
import com.project.vo.TripAccessVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Component
public class TravelHandleChain {
    @Autowired
    List<RiskHandle> list=new ArrayList<>();

    public void handle(TripAccessVO tripAccessVO, List<RiskController> riskRule, List<ErrorMessage> errorMessageList){
        if (!Objects.isNull(list)){
            for (RiskHandle handle:list){
                handle.RiskAssess(tripAccessVO,riskRule,errorMessageList);
                if (errorMessageList.size()>0){
                    break;
                }
            }
        }
    }
}

